﻿#region Copyright (c) 2000-2013 Developer Express Inc.
/*
{*******************************************************************}
{                                                                   }
{       Developer Express .NET Component Library                    }
{                                                                   }
{                                                                   }
{       Copyright (c) 2000-2013 Developer Express Inc.              }
{       ALL RIGHTS RESERVED                                         }
{                                                                   }
{   The entire contents of this file is protected by U.S. and       }
{   International Copyright Laws. Unauthorized reproduction,        }
{   reverse-engineering, and distribution of all or any portion of  }
{   the code contained in this file is strictly prohibited and may  }
{   result in severe civil and criminal penalties and will be       }
{   prosecuted to the maximum extent possible under the law.        }
{                                                                   }
{   RESTRICTIONS                                                    }
{                                                                   }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES           }
{   ARE CONFIDENTIAL AND PROPRIETARY TRADE                          }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS   }
{   LICENSED TO DISTRIBUTE THE PRODUCT AND ALL ACCOMPANYING .NET    }
{   CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY.                 }
{                                                                   }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED      }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE        }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE       }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT  }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                      }
{                                                                   }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON       }
{   ADDITIONAL RESTRICTIONS.                                        }
{                                                                   }
{*******************************************************************}
*/
#endregion Copyright (c) 2000-2013 Developer Express Inc.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
#if SL
using DevExpress.Xpf.Core.WPFCompatibility;
using Control = DevExpress.Xpf.Core.WPFCompatibility.SLControl;
using RoutedEvent = DevExpress.Xpf.Core.WPFCompatibility.SLRoutedEvent;
using RoutedEventArgs = DevExpress.Xpf.Core.WPFCompatibility.SLRoutedEventArgs;
using System.Windows.Markup;
using System.ComponentModel;
#endif
namespace UColor.WPF {
#if SL
	[ContentProperty("Content"), DefaultProperty("Content")]
	public class DemoExpander : SLControl {
		public static DependencyProperty HeaderProperty;
		public static DependencyProperty IsExpandedProperty;
		public static DependencyProperty ContentProperty;
		public static readonly RoutedEvent ExpandedEvent;
		public static readonly RoutedEvent CollapsedEvent;
		static DemoExpander() {
			Type ownerType = typeof(DemoExpander);
			HeaderProperty = DependencyProperty.Register("Header", typeof(object), ownerType, new PropertyMetadata(null));
			IsExpandedProperty = DependencyProperty.Register("IsExpanded", typeof(bool), ownerType, new PropertyMetadata(true, OnIsExpandedChanged));
			ContentProperty = DependencyProperty.Register("Content", typeof(object), ownerType, new PropertyMetadata(null));
			ExpandedEvent = EventManager.RegisterRoutedEvent("Expanded", RoutingStrategy.Bubble, typeof(RoutedEventHandler), ownerType);
			CollapsedEvent = EventManager.RegisterRoutedEvent("Collapsed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), ownerType);
		}
		private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
			((DemoExpander)d).OnIsExpandedChanged();
		}
		public DemoExpander() {
			this.DefaultStyleKey = typeof(DemoExpander);
		}
		public object Header {
			get { return GetValue(HeaderProperty); }
			set { SetValue(HeaderProperty, value); }
		}
		public bool IsExpanded {
			get { return (bool)GetValue(IsExpandedProperty); }
			set { SetValue(IsExpandedProperty, value); }
		}
		public object Content {
			get { return (object)GetValue(ContentProperty); }
			set { SetValue(ContentProperty, value); }
		}
		public event RoutedEventHandler Expanded {
			add { this.AddHandler(ExpandedEvent, value); }
			remove { this.RemoveHandler(ExpandedEvent, value); }
		}
		public event RoutedEventHandler Collapsed {
			add { this.AddHandler(CollapsedEvent, value); }
			remove { this.RemoveHandler(CollapsedEvent, value); }
		}
		void OnIsExpandedChanged() {
			RaiseEvent(new RoutedEventArgs() { Source = this, RoutedEvent = IsExpanded ? ExpandedEvent : CollapsedEvent });
		}
	}
#else
	public class DemoExpander : Expander {
		static DemoExpander() {
			DefaultStyleKeyProperty.OverrideMetadata(typeof(DemoExpander), new FrameworkPropertyMetadata(typeof(DemoExpander)));
		}
	}
#endif
}
